<template>
	<footer class="footer">
		<span class="todo-count">剩余<strong>{{ sum }}</strong></span>
		<ul class="filters">
			<li>
				<a  href="javascript:;"
				:class="{selected: type === 'all'}"
				@click="selected('all')"
				>全部</a>
			</li>
			<li>
				<a href="javascript:;"
				:class="{selected: type === 'active'}"
				@click="selected('active')"
				>未完成</a>
			</li>
			<li>
				<a href="javascript:;"
				:class="{selected: type === 'completed'}"
				@click="selected('completed')"
				>已完成</a>
			</li>
		</ul>
		<button class="clear-completed" @click="clear">清除已完成</button>
	</footer>
</template>

<script>
	export default {

		props: ["arr"],

		data () {
			return {
				type: ''
			}
		},

		methods: {
			clear(){
				this.$emit("clear")
			},
			selected(type){
				this.type = type
				this.$emit("selected", this.type)
			}
		},

		computed: {
			sum(){
				return this.arr.filter(item => item.isDone !== true).length
			}
		}
	}
</script>
